package com.teaphy.coroutinecrawler.flow.operators.intermediate

import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.fold
import kotlinx.coroutines.runBlocking
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime


@ExperimentalTime
fun main() = runBlocking {
    val sumDuration = measureTime {
        val sum = flowOf(1, 2, 3)
            .fold(0) {
                    acc, value ->
                delay(100)
                acc + value
            }
        println("sum: $sum")
    }

    println("sumDuration: $sumDuration")

    println("Done")
}